<?php
	$sections = $this->sections;
	$categories = $this->categories;
	$sec_items = $this->sec_items;
?>
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<?php 
	$count = count($sections);
	$mod = $count%2;
?>
<?php if ($mod==0){?>
	<?
		$i=0;
		foreach ($sections as $section) {
			if ($i%2 == 0){
				echo '<tr><td width="49%" valign="top">';
			}
	?>
		<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<tr>
				<td class="blue_box_left"><img src="<?= $this->baseUrl ?>/public/images/frontend/pixel.gif" width="2" /></td>
				<td class="blue_box_center" width="100%">
					<?= $section->sec_name; ?>
				</td>
				<td class="blue_box_right"><img src="<?= $this->baseUrl ?>/public/images/frontend/pixel.gif" width="2" /></td>
			</tr>
			<tr>
				<td colspan="3" width="100%" style="border: 1px solid #9bbdd3; border-top: 0px;">
					<table cellpadding="4" cellspacing="0" width="100%" border="0">
						<tr>
							<td align="left" width="100%" style="background-color: #eaf4f9; border-bottom: 1px solid #dbecf4; color: #8fb4ce; font-size: 8pt;">
								<?php 
									$k=0;
									foreach ($categories as $category) {
																				
										if ($category->sec_id == $section->sec_id){
								?>
									<? if ($k !=0 ) echo "&nbsp;|&nbsp;"; ?><a class="normal2" href="#sample"><?= $category->cat_name; ?></a>
								<?
										$k++;
										}
									}
									if ($k==0) echo "&nbsp;";
								?>							
							</td>
						</tr>
					</table>
					<table cellpadding="4" cellspacing="0" border="0" width="100%">					
						<? 
							if (key_exists($section->sec_id, $sec_items)) $items = $sec_items[$section->sec_id];
							if (isset($items)){ 
								foreach ($items as $item) {
									$image = $item->img_path.$item->img_title;
									if (!$image) $image = $this->baseUrl."/public/images/samples/hang_1.jpg";
						?>
							<tr style="background-color: #f1f7fa">
								<td width="10%" valign="middle" style="font-size: 9pt; color: #A9A9A9">
									<img src="<?= $image ?>" width="30" height="20" border="0" />
								</td>
								<td width="90%" valign="top" style="font-family: tahoma, verdana, arial; font-size: 9pt;">
									<a class="normal2" href="#sample">
										<?= $this->utilities->substring($item->com_name); ?>
									</a>
								</td>
							</tr>
						<?  }} ?>
					</table>
				</td>
			</tr>
		</table>
		<?php if ($i%2 == 0){ ?>
		</td><td width="1%">&nbsp;</td><td width="50%" valign="top">
		<?php }else{ ?>
					</td>
				</tr>
				<? if ($i != $count-1){ ?>
					<tr>
				  		<td colspan="3">
				  			<p style="padding: 8px 0 8px 0;"><a class="normal2" href="<?= $this->baseUrl ?>/account/register" title="Join now!"><img alt="Join now!" src="<?= $this->baseUrl ?>/public/images/frontend/font-page-image.jpg" border="0" /></a></p>
						</td>
				  	</tr>
				<? } ?>
		<?php } ?>
		<?php 
			$i++; 
		} 
		?>
		
<? } else { ?>	
	<?
		$i=0;
		foreach ($sections as $section) {
			if ($i < $count-1){
			if ($i%2 == 0){
				echo '<tr><td width="49%" valign="top">';
			}
	?>
		<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<tr>
				<td class="blue_box_left"><img src="<?= $this->baseUrl ?>/public/images/frontend/pixel.gif" width="2" /></td>
				<td class="blue_box_center" width="100%">
					<?= $section->sec_name; ?>
				</td>
				<td class="blue_box_right"><img src="<?= $this->baseUrl ?>/public/images/frontend/pixel.gif" width="2" /></td>
			</tr>
			<tr>
				<td colspan="3" width="100%" style="border: 1px solid #9bbdd3; border-top: 0px;">
					<table cellpadding="4" cellspacing="0" width="100%" border="0">
						<tr>
							<td align="left" width="100%" style="background-color: #eaf4f9; border-bottom: 1px solid #dbecf4; color: #8fb4ce; font-size: 8pt;">
								<?php 
									$k=0;
									foreach ($categories as $category) {
																				
										if ($category->sec_id == $section->sec_id){
								?>
									<? if ($k !=0 ) echo "&nbsp;|&nbsp;"; ?><a class="normal2" href="#sample"><?= $category->cat_name; ?></a>
								<?
										$k++;
										}
									}
									if ($k==0) echo "&nbsp;";
								?>							
							</td>
						</tr>
					</table>
					<table cellpadding="4" cellspacing="0" border="0" width="100%">
						<? 
							if (key_exists($section->sec_id, $sec_items)) $items = $sec_items[$section->sec_id];
							if (isset($items)){ 
								foreach ($items as $item) {
									$image = $item->img_path.$item->img_title;
									if (!$image) $image = $this->baseUrl."/public/images/samples/hang_1.jpg";
						?>
							<tr style="background-color: #f1f7fa">
								<td width="10%" valign="middle" style="font-size: 9pt; color: #A9A9A9">
									<img src="<?= $image ?>" width="30" height="20" border="0" />
								</td>
								<td width="90%" valign="top" style="font-family: tahoma, verdana, arial; font-size: 9pt;">
									<a class="normal2" href="#sample">
										<?= $this->utilities->substring($item->com_name); ?>
									</a>
								</td>
							</tr>
						<?  }} ?>
					</table>
				</td>
			</tr>
		</table>
		<?php if ($i%2 == 0){ ?>
		</td><td width="1%">&nbsp;</td><td width="50%" valign="top">
		<?php } else { ?>
					</td>
				</tr>				
				<tr>
			  		<td colspan="3">
			  			<p style="padding: 8px 0 8px 0;"><a class="normal2" href="<?= $this->baseUrl ?>/account/register" title="Join now!"><img alt="Join now!" src="<?= $this->baseUrl ?>/public/images/frontend/font-page-image.jpg" border="0" /></a></p>
					</td>
			  	</tr>				
		<?php } ?>
		<?php } else { ?>
			<tr>
			  	<td colspan="3">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td class="blue_box_left"><img src="<?= $this->baseUrl ?>/public/images/frontend/pixel.gif" width="2" /></td>
							<td class="blue_box_center" width="100%">
								<?= $section->sec_name; ?>
							</td>
							<td class="blue_box_right"><img src="<?= $this->baseUrl ?>/public/images/frontend/pixel.gif" width="2" /></td>
						</tr>
						<tr>
							<td colspan="3" width="100%" style="border: 1px solid #9bbdd3; border-top: 0px;">
								<table cellpadding="4" cellspacing="0" width="100%" border="0">
									<tr>
										<td align="left" width="100%" style="background-color: #eaf4f9; border-bottom: 1px solid #dbecf4; color: #8fb4ce; font-size: 8pt;">
											<?php 
												$k=0;
												foreach ($categories as $category) {
																							
													if ($category->sec_id == $section->sec_id){
											?>
												<? if ($k !=0 ) echo "&nbsp;|&nbsp;"; ?><a class="normal2" href="#sample"><?= $category->cat_name; ?></a>
											<?
													$k++;
													}
												}
												if ($k==0) echo "&nbsp;";
											?>			
										</td>
									</tr>
								</table>
								<table cellpadding="4" cellspacing="0" border="0" width="100%">
								<? 
									if (key_exists($section->sec_id, $sec_items)) $items = $sec_items[$section->sec_id];
									if (isset($items)){ 
										foreach ($items as $item) {
											$image = $item->img_path.$item->img_title;
											if (!$image) $image = $this->baseUrl."/public/images/samples/hang_1.jpg";
								?>
									<tr style="background-color: #f1f7fa">
										<td width="5%" valign="middle" style="font-size: 9pt; color: #A9A9A9">
											<img src="<?= $image ?>" width="30" height="20" border="0" /></td>
										<td width="90%" valign="top" style="font-family: tahoma, verdana, arial; font-size: 9pt;">
											<a class="normal2" href="#sample">
												<?= $this->utilities->substring($item->com_name); ?>
											</a>
										</td>
									</tr>
								<?  }} ?>
							</table>
							</td>
						</tr>
					</table>    
				</td>
			  </tr>
		<? }?>
<?	$i++; }//end for. ?>
<? } ?>
</table>